using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DataHelper.DAL
{
    public class News
    {
private static  string m_trConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

       #region NewsSelectAll
        public static SqlDataReader NewsSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
                return SqlHelper.ExecuteReader(ConnectionString, "NewsSelectAllRows",strSearch,top,bottom);
            return SqlHelper.ExecuteReader(m_trConnectionString, "NewsSelectAllRows",strSearch,top,bottom);
        }
        #endregion
       #region NewsSelectRow
        public static SqlDataReader NewsSelectRow(int ID, int LangID, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
                return SqlHelper.ExecuteReader(ConnectionString, "NewsSelectRow", ID, LangID);
            return SqlHelper.ExecuteReader(m_trConnectionString, "NewsSelectRow", ID, LangID);
        }
        #endregion
       #region NewsInsertRow
        public static void NewsInsertRow(int ID, int LangID, int TypeID, string Title, string Link, string Description, string Content, string Image, string RefLink, string SEO, DateTime CreatedDate, string CreatedUser, DateTime UpdatedDate, string UpdatedUser, bool IsPin, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "NewsInsertRow", ID, LangID, TypeID, Title, Link, Description, Content, Image, RefLink, SEO, CreatedDate, CreatedUser, UpdatedDate, UpdatedUser, IsPin, IsDeleted);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "NewsInsertRow", ID, LangID, TypeID, Title, Link, Description, Content, Image, RefLink, SEO, CreatedDate, CreatedUser, UpdatedDate, UpdatedUser, IsPin, IsDeleted);
        }
        #endregion
       #region NewsUpdateRow
        public static void NewsUpdateRow(int ID, int LangID, int TypeID, string Title, string Link, string Description, string Content, string Image, string RefLink, string SEO, DateTime CreatedDate, string CreatedUser, DateTime UpdatedDate, string UpdatedUser, bool IsPin, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "NewsUpdateRow", ID, LangID, TypeID, Title, Link, Description, Content, Image, RefLink, SEO, CreatedDate, CreatedUser, UpdatedDate, UpdatedUser, IsPin, IsDeleted);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "NewsUpdateRow", ID, LangID, TypeID, Title, Link, Description, Content, Image, RefLink, SEO, CreatedDate, CreatedUser, UpdatedDate, UpdatedUser, IsPin, IsDeleted);
        }
        #endregion
       #region NewsDeleteRow
        public static void NewsDeleteRow(int ID, int LangID, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "NewsDeleteRow", ID, LangID);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "NewsDeleteRow", ID, LangID);
        }
        #endregion

    }
}

